<h1>Editing network</h1>

<% form_for(@network) do |f| %>
  <%= f.error_messages %>

  <p>
    <%= f.label :name %>
    <%= f.text_field :name %>
  </p>
  <p>
    <%= f.label :computer_id %>
	<% computers = Computer.all %>
    <%= f.select(:computer_id, computers.collect {|c| [c.name, c.id] },:selected => @network.computer_id, :include_blank => true)%>
  </p>
  <p>
    <%= f.label :submask %>
    <%= f.text_field :submask %>
  </p>
  
  <p>
  <h2>Rooms :</h2>
  <table border="2">
  	<tr class="ui-state-default">
  	  <th>Available</th>
  	  <th>Belongs to me</th>
  	</tr>
  	<tr>
  	  <td id='trash_room'>
  		 <% Room.all.each do |room| %>
    	   <%if !@network.rooms.include?(room)%>
	     	 <%= render :partial => 'networks/network_room', :locals => {:room => room}%>
      	   <%end%>
		 <% end %>
	  </td>
	  <td id='container_room'>
  		<% Room.all.each do |room| %>
			<%if @network.rooms.include?(room)%>
	      	  <%= render :partial => 'networks/network_room', :locals => {:room => room}%>
			<%end%>
		<%end%>
	  </td>
	</tr>
  </table>
  <%= drop_receiving_element('trash_room',
    :accept => "dragable",
    :with   => "'room_id=' + (element.id.split('_').last()) + '&network_id=#{@network.id.to_s}'",
    :url    => {:action=>:delete_room}
  )%>
  <%= drop_receiving_element('container_room',
    :accept => "dragable",
    :with   => "'room_id=' + (element.id.split('_').last()) + '&network_id=#{@network.id.to_s}'",
    :url    => {:action=>:add_room}
  )%>
  </p> 
  <p>
    <%= f.submit 'Update' %>
  </p>
<% end %>
	
	<% link_to @network, :class => "ui-state-default ui-corner-all dialog_link" do %>
			<span class="ui-icon ui-icon-search"></span>View
	<% end %>&nbsp;
	<% link_to networks_path, :class => 'ui-state-default ui-corner-all dialog_link' do %>
		<span class="ui-icon ui-icon-arrowreturnthick-1-w"></span>Back
	<% end %>
